<?php
	include_once '../config.inc.php';
	$stmt = $pdo->prepare('select * from kp_goods_class where (pid is null or pid = \'\') and state = 1 order by cid asc');
	$stmt->execute();
	$cArrs = $stmt->fetchAll(PDO::FETCH_ASSOC);
	//print_r($cArrs);
	
?>

<!DOCTYPE html>
<html lang="zh">
<head>
	<meta charset="UTF-8" />
	<meta name="viewport" content="width=device-width, initial-scale=1.0" />
	<meta http-equiv="X-UA-Compatible" content="ie=edge" />
	<title>分类管理</title>
	<script src="../js/jquery-3.1.1.js" type="text/javascript" charset="utf-8"></script>
	<script src="js/kpclass.js" type="text/javascript" charset="utf-8"></script>
	<link rel="stylesheet" type="text/css" href="css/kpclass.css"/>
</head>
<body>
	<div class="mtitle">
		商品分类管理:分级显示
	</div>
	
	<div id="kpclass">
		<!--分类显示atart-->
		<?php
			foreach($cArrs as $cArr1){
		
		?>
		
		<ul class="c1">
			<li class="id" title="ID"><?php echo $cArr1['id']; ?></li>
			<li class="cid" title="分类编号"><?php echo $cArr1['cid']; ?></li>
			<li class="cname" title="分类名称"><?php echo $cArr1['cname']; ?></li>
			<li class="edit">[改]</li>
			<li class="del">[删]</li>
				
			<?php
				$stmt = $pdo->prepare('select * from kp_goods_class where pid=? and state = 1');
				$stmt->execute(array($cArr1['cid']));
				$cArr2s = $stmt->fetchAll(PDO::FETCH_ASSOC);
				foreach($cArr2s as $cArr2){
			?>
			<ul class="c2">
				<li class="id" title="ID"><?php echo $cArr2['id']; ?></li>
				<li class="cid" title="分类编号"><?php echo $cArr2['cid']; ?></li>
				<li class="pid" title="上级分类编号"><?php echo $cArr2['pid']; ?></li>
				<li class="cname" title="分类名称"><?php echo $cArr2['cname']; ?></li>
				<li class="edit">[改]</li>
				<li class="del">[删]</li>
			</ul>
			<?php
				}
			?>
			
		<!--	<ul class="c2">
				<li class="cid" title="分类编号">0101</li>
				<li class="cname" title="分类名称">二级分类</li>
				
			</ul>-->
		</ul>
		<?php
			} 
		 ?>
		 <hr style="float: left; width: 90%; margin: 10px;" />
		 
		 <ul class="c3">
		 		<li class="text">编号:</li>
				<li class="cid" contenteditable="true" title="分类编号"></li>
				<li class="text">上级分类编号:</li>
				<li class="pid" title="上级分类编号"></li>
				<li class="text">分类名称:</li>
				<li class="cname" contenteditable="true" title="分类名称"></li>
				<li class="add">[增加分类]</li>
			</ul>
		 <p style=" float: left; font-size: 12px; color: #999; margin-left: 15px;">帮助-分类编号填写:一级写2位数字,数字用于排序显示,二级用四位数字,前两位表示上级分类编号!</p>
		 
		<!--分类显示end-->
	</div>
</body>
</html>